This is a mini project to price exotic options for the appropriate form of payoff, to consider Asian and lookback options, which are path-dependent options. Firstly, we define state variables as:
Mean:
Max:
Min:
Where, is a set of sampling index from asset path by a certain period which can be chosen as 1 day,1 week,1 month, 1 quarter,semi-year,1 year and so on. Mean is a function of set to return the mean of its elements Max is a function of set to return the maximum of its elements. Min is a function of set to return the minimum of its elements.
Then, We set is delivery price, the payoff functions of different exotic options we considered are listed as follow:
| option | payoff function |
|---|---|
| Asian call option with fixed delivery price: | |
| Asian put option with fixed delivery price: | |
| Asian call option with floating delivery price: | |
| Asian put option with floating delivery price: | |
| Lookback call option with fixed delivery price: | |
| Lookback put option with fixed delivery price: | |
| Lookback call option with floating delivery price: | |
| Lookback put option with floating delivery price: |
It is hard to find closed-form solutions for prices. More often than not we must solve option-pricing problems by numerical means. The most useful numerical techniques are Monte Carlo simulations and finite-difference methods.
However, path-dependent options are added demension as a state variable so it is difficult to deduce PDE and implement finite-difference methods. Thus, this project mainly consider Monte Carlo scheme.
Monte Carlo methods are any process that consumes random numbers. These are part of computational algorithms which are based on random sampling to obtain numerical results. Monte Carlo methods are proved to be a very valuable and flexible computational tool in finance and is one of the most widely used methods for optimization and numerical integration problems.
These methods are widely used in high dimensional problems. pricing exotics and complex derivatives where closed form solutions are not directly available. Monte Carlo methods are not just adapted in pricing complex derivatives, It is also extensively used in estimating the portfolio risk such as Value-at-Risk and Expected Shortfall and used in the calculation of worst-case scenarios in stress testing. The downside to that is, it is very computational intensive and demanding.
The mathematics that we need to perform a Monte Carlo simulation can be very basic. Use the expected value of the discounted payoff under the risk-neutral density
Martingale theory can deduce arbitrage-free principle.It is also seen that Martingale theory is consistent with Black-scholes PDE by using Feynman-Kac formula.Thus,justification for the Martingale theory to price is obvious.
The reasons we choose the Monte Carlo scheme are still including:
The numerical procedure of Monte Carlo algorithm for option pricing is generally summarized as follow:
Step1 : Simulate the risk-neutral Brownian motion starting at today’s value of the asset over the required time horizon. This gives one realization of the underlying price path.
Step2 : For this realization calculate the option payoff. Note that we have to caculate state variables based on simulated price path which are putted into payoff function
Step3 : Perform many more such realizations over the time horizon.
The key procedure is how to simulate the underlying price path. Price process follows the risk-neutral stochastic differential equation which may not have closed-form solutions. A general method that always works is to use a discrete version of the stochastic differential equation for price of which a typical representative is Euler-Maruyama scheme
where is from a standardized Normal distribution, is risk-free interest rate
This method has an error of . Because we are only simulating a finite number of an infinite number of possible paths, the error due to using realizations of the asset price paths is .
We set an initial example using the following set of sample data:
It is necessary to set some numerical parameters:
This project is aimed to solve initial example by choose different sampling periods, such as 1 day,1 week,1 month,1 quarter,semi-year,1 year. Then we set sampling period to be 1 month, vary the data to see the affect on the option prices. In the appendix we also make a detailed exploration to analyse error.
It is necessary to set basic configuration before explorate. Some required libraries will be imported.Some functions will be also defined, though may be redefined below by different problem.
# Importing libraries
import pandas as pd
from numpy import *
# Libraries for plotting
import matplotlib.pyplot as plt
import cufflinks as cf
cf.set_config_file(offline=True)
# Set max row to 300
pd.set_option('display.max_rows', 300)
# Ignore warnings
import warnings
warnings.filterwarnings('ignore')
The function simulate_path is used to simulate the underlying asset price paths. it has 6 aguments:
The return is a array shape of which is .Its rows represent time, columns represent every simulated path.
def simulate_path(s0, mu, sigma, horizon, timesteps, n_sims):
# Set the random seed for reproducibility
# Same seed leads to the same set of random values
random.seed(10000)
# Read parameters
S0 = s0 # initial spot level
r = mu # mu = rf in risk neutral framework
T = horizon # time horizion
t = timesteps # number of time steps
n = n_sims # number of simulation
# Define dt
dt = T/t # length of time interval
# Simulating 'n' asset price paths with 't' timesteps
S = zeros((t+1, n))
S[0] = S0
for i in range(1, t+1):
z = random.standard_normal(n) # psuedo random numbers
S[i]=S[i-1]+r*S[i-1]*dt+sigma * sqrt(dt)*S[i-1]*z # Euler-Maruyama scheme
return S
The function caculate_exotics_price is used to caculate exotics prices. it has 6 aguments:
The return is a list containing different extotic option prices.
def caculate_exotic_price(S_path,sampling_period,E,r,horizon):
S=S_path #simulated price path data,expected as a dataframe,of which rows represent time,columns represent every simulated path
sp=sampling_period #sampling_period refers the days sampling once
#For example,sample_days=5,meaning that 5,10,15,...,250 are sampled to caculate Asian average and lookback max & min
T=horizon
final_price=S.iloc[-1] #final price at maturity
path_mean=S.iloc[sp::sp].mean(axis=0) # state variable MEAN related to sample period,a path has one
path_max=S.iloc[sp::sp].max(axis=0) # state variable MAX related to sample period,a path has one
path_min=S.iloc[sp::sp].min(axis=0) # state variable MIN related to sample period,a path has one
# Calculate the discounted value of the expeced payoff
#vanilla
C0 = exp(-r*T) * mean(maximum(final_price - E, 0))
P0 = exp(-r*T) * mean(maximum(E - final_price, 0))
#fixed Asian
fix_Asian_C = exp(-r*T) * mean(maximum(path_mean - E, 0))
fix_Asian_P = exp(-r*T) * mean(maximum(E - path_mean, 0))
float_Asian_C = exp(-r*T) * mean(maximum(path_mean - final_price, 0))
float_Asian_P = exp(-r*T) * mean(maximum(final_price - path_mean, 0))
fix_Lookback_C = exp(-r*T) * mean(maximum(path_max - E, 0))
fix_Lookback_P = exp(-r*T) * mean(maximum(E - path_min, 0))
float_Lookback_C = exp(-r*T) * mean(maximum(path_max - final_price, 0))
float_Lookback_P = exp(-r*T) * mean(maximum(final_price - path_min, 0))
# the caculated results are putted into 'reslut_list' as a list
reslut_list=[C0,P0,fix_Asian_C,fix_Asian_P,float_Asian_C,float_Asian_P,\
fix_Lookback_C,fix_Lookback_P,float_Lookback_C,float_Lookback_P]
return reslut_list
We set inputs according to initial example above. Simulate underlying asset prices and visualize them.
# Assign simulated price path to dataframe for analysis and plotting
price_path = pd.DataFrame(simulate_path(100, 0.05, 0.20, 1, 252, 100000)) # timesteps=252 meaning simulating by days
# Verify the generated price paths
price_path.tail()
# Plot the histogram of the simulated price path at maturity
price_path.iloc[-1].iplot(kind='histogram', title= 'Simulated Underlying Asset Price at Maturity', bins=100)
# Plot simulated price paths,1-100th
price_path.iloc[:,:100].iplot(title='Simulated Underlying Asset Price Paths', xTitle='Time Steps', yTitle='Price')
Analyse: From the histogram above, it is clearly seen that price at maturity is subject to right-skewed log-normal distribution. Some extreme data bigger than mean about 100 is dangerous for call option short compared standard normal distribution.
Caculate diffrent option prices by sampling by 1 Day, 1 Week, 1 Month, 1 quarter, semi-year,1 year based on the data simulated above.
Change_range=[1,5,21,63,126,252] #Sampling by 1 Day,1 Week,1 Month,1 quarter,semi-year,1 year
Change=[]# set a list to save data
for d in Change_range:
reslut_list=caculate_exotic_price(price_path,d,100,0.05,1) # for different sampling periods caculate extotic price
Change.append(reslut_list)# put caculate reslut into the list
df=pd.DataFrame(Change)# to dataframe
df.columns=["European Call", "European Put", "Fix Asian Call", "Fix Asian put",\
"Float Asian Call","Float Asian Put","Fix Lookback Call","Fix Lookback Put",\
"Float Lookback Call","Float Lookback Put"]
df.index=Change_range
df.index.name="Sampling Period"
round(df,4)# keep 4 decimals
Analyse: From the table, it clearly seen that:
Firstly, European call and put option is not related to sampling period since their payoff functions are only about final price.
Then, Asian call and put with fixed delivery increase with the increase of sampling period,since the mean function is increasingly volatile when sampling period increases. If the sampling period is 252, the mean is reduced to final price , so the price of Asian call and put with fixed delivery is same as European call and put option respectively.
However, lookback call and put with fixed delivery has the opposite conclusion: the option prices decrease with the increase of sampling period as a result of stability of maximum and minimum function with sampling period increasing.
Last, All option with float delivery decrease with the increase of sampling period because the mean, maximum and minimum are all reduced to final price, which are equals float delivery if the sampling period is 252. Under this situation, their prices equal 0 though there hardly exists option of which sampling period equals time to expiry in practice. We assume this only for mathematic analysis.
Set sampling period to be 21. Caculate diffrent option prices with varies from 60 to 150, step is 5.
Change_range=range(60,155,5)
Change=[]
for s0 in Change_range:
price_path = pd.DataFrame(simulate_path(s0, 0.05, 0.20, 1, 252, 100000)) # timesteps=252 meaning simulating by days
reslut_list=caculate_exotic_price(price_path,21,100,0.05,1)
Change.append(reslut_list)
##################################### make table ####################################################
df=pd.DataFrame(Change)
df.columns=["European Call", "European Put", "Fix Asian Call", "Fix Asian put",\
"Float Asian Call","Float Asian Put","Fix Lookback Call","Fix Lookback Put",\
"Float Lookback Call","Float Lookback Put"]
df.index=Change_range
df.index.name="S0"
##################################### visualize ####################################################
df.iplot(title='change S0', xTitle='S0', yTitle='Price')
round(df,4)
Analyse: From the figure, it is clearly seen that all call option prices increase with the rise of while all put option prices decrease. Moreover, the change magnitude of options with fixed delivery price is larger than options with floating delivery price.
For European call option, the price is a convex function of the delivery price. We can prove it easily.The payoff function is a convex function of the delivery price. since expection integral has property of convexity preserving, so
is also a convex function of the delivery price, where is transition density function of underlying price.
It is easy to prove that a line joining any two points on the graph of convex function lies on or above the graph. Let denote the call option price as a function of strike . Then this is equivalent to saying, for ,
, for all
The important thing to note here is that the final payoff is convex in strike for a fixed value in the underlying, that is the function is convex in . With this in mind, consider a portfolio long call options struck at , long options struck at and short one option struck at (all options with the same maturity). Since the final payoff is convex in strike, holds at the expiry of the options and we therefore have that our portfolio has non-negative value at expiry. If violates convexity at some time before expiry, We can buy/short the portfolio above to make butterfly arbitrage.
The similary conclusion can also be drawed about put option. But what about extotic options? Are their convexities different? We change the from to to see the affect on the option price with setting sampling period is 21.We eliminates options with floating delivery not related to .
price_path = pd.DataFrame(simulate_path(100, 0.05, 0.20, 1, 252, 100000)) # reset
Change_range=range(50,155,5)
Change=[]
for E in Change_range:
reslut_list=caculate_exotic_price(price_path,21,E,0.05,1)
Change.append(reslut_list)
##################################### make table ####################################################
df=pd.DataFrame(Change)
df.columns=["European Call", "European Put", "Fix Asian Call", "Fix Asian put",\
"Float Asian Call","Float Asian Put","Fix Lookback Call","Fix Lookback Put",\
"Float Lookback Call","Float Lookback Put"]
df.index=Change_range
df.index.name="E"
##################################### visualize ####################################################
names=["European Call","European Put","Fix Asian Call","Fix Asian put","Fix Lookback Call","Fix Lookback Put"]
df=df[names]
df.iplot(title='Change E', xTitle='E', yTitle='Price')
round(df,4)
Analyse: According the figure above, European options and extotic options are all convex functions of the delivery price from our intuition. Lookback call with fixed delivery price European call option Asian call option with fixed delivery price consitently regardless of what E equals. However, for put option, Asian put option with fixed delivery price and European put option violate this consistence.
This give a approxiamte convexity estimate formula:
where ,.
We set , which is not very tiny but still can measure convexity roughly.
convex=4*(df.shift(-1)+df.shift(1)-2*df).round(6)#percentage
convex.iplot(title='Convexity Related to E', xTitle='E', yTitle='Convexity')
convex
Analyse: The results from table above are percentage. For European option and Asian option with fixed delivery price, the convexity of call and put are same. Analogy with the gamma of call and put are same, it can be understood easily. What figure above shows consistents with our experience is that the convexity of European option is greatest when it is at the money. And exotic options are no exceptiones. The data shows that the convexity of Asian option at the money is greater than any others, which implies there may be more butterfly arbitrage profits if opportunity appears.
Set sampling period to be 21. Caculate diffrent option prices with varies from 0.05 to 0.35, step is 0.01.
Change_range=arange(0.05,0.35,0.01)
Change=[]
for Sig in Change_range:
price_path = pd.DataFrame(simulate_path(100, 0.05, Sig, 1, 252, 100000)) # timesteps=252 meaning simulating by days
reslut_list=caculate_exotic_price(price_path,21,100,0.05,1)
Change.append(reslut_list)
##################################### make table ####################################################
df=pd.DataFrame(Change)
df.columns=["European Call", "European Put", "Fix Asian Call", "Fix Asian put",\
"Float Asian Call","Float Asian Put","Fix Lookback Call","Fix Lookback Put",\
"Float Lookback Call","Float Lookback Put"]
df.index=Change_range
df.index.name="sigma"
##################################### visualize ####################################################
df.iplot(title='Change Vol', xTitle='Vol', yTitle='Price')
Analyse: As we know, option prices rise as volatility rises. From the figure above, vega of lookback options is larger than Asian options because the trend of lookback options is more steep.
Stochastic volatility models take both the underlying price process and volatility process to be stochastic. There are many popular forms for the volatility process, the SABR model, for example, under the future measure, uses
where is future price , is elasticity of Variance, is stochastic volatility rate, is the volatility of volatility. and are Brownian motions with correlation . and are initial future price and volatility respectively.
For
note
by lemma,we can get
When interest rate is not random, . We can use the expected value of the discounted payoff under the future measure (or say )
The function SV_simulate_path is used to simulate the underlying asset price paths under stochastic volatility asumption. it has 8 aguments:
The return is a array shape of which is . Its rows represent time, columns represent every simulated path.
# redefine simulate_path
#to make sigma be a function of S,which is called stocastical volatility,a represent of which is SABR
def SV_simulate_path(s0, mu, beta, v, alpha, rho, horizon, timesteps, n_sims):
# Set the random seed for reproducibility
# Same seed leads to the same set of random values
random.seed(10000)
# Read parameters
S0 = s0 # initial spot level
r = mu # mu = rf in risk neutral framework
T = horizon # time horizion
t = timesteps # number of time steps
n = n_sims # number of simulation
# Define dt
dt = T/t # length of time interval
# Simulating 'n' asset price paths with 't' timesteps
S = zeros((t+1, n))
a= zeros((t+1, n))
S[0] = S0
a[0] = alpha
for i in range(1, t+1):
z=random.multivariate_normal([0,0],[[1,rho],[rho,1]],size=n)
w1=z[:,0]
w2=z[:,1]
a[i]=a[i-1]+v*a[i-1]*sqrt(dt)*w2
S[i]=S[i-1]+r*S[i-1]*dt+a[i]*exp((beta-1)*r*(T-i*dt))*pow(S[i-1],beta)* sqrt(dt)*w1 # Euler-Maruyama scheme
return S
Simulate underlying asset prices under stochastic volatility asumption and visualize them.
We set beta=1, v=0.4, alpha=0.2, rho=0.2. Other parameters are the same as default values above.
Next we only let one parameter varies, and others keep the above settings.
SV_price_path = pd.DataFrame(SV_simulate_path(s0=100, mu=0.05, beta=1, v=0.3, alpha=0.2, rho=0.2, horizon=1, timesteps=252, n_sims=100000))
# timesteps=252 meaning simulating by days
# Plot the histogram of the simulated price path at maturity
SV_price_path.iloc[-1].iplot(kind='histogram', title= 'Simulated Underlying Asset Price at Maturity under Stochastic Volatility Asumption', bins=100)
# Plot simulated price paths,1-100th
SV_price_path.iloc[:,:100].iplot(title='Simulated Underlying Asset Price Paths under Stochastic Volatility Asumption', xTitle='Time Steps', yTitle='Price')
Analyse: Contrast constant volatility, simulated underlying asset prices at maturity under atochastic volatility asumption look higher peak and fat tail. Additionally, there are also more extreme data.
Caculate diffrent option prices with varies from 0 to 1, step is 0.1.
Change_range=arange(0.00,1,0.1)
Change=[]
for v in Change_range:
SV_price_path = pd.DataFrame(SV_simulate_path(s0=100, mu=0.05, beta=1, v=v, alpha=0.2, rho=0.2, horizon=1, timesteps=252, n_sims=100000))
reslut_list=caculate_exotic_price(SV_price_path,21,100,0.05,1)
Change.append(reslut_list)
##################################### make table ####################################################
df=pd.DataFrame(Change)
df.columns=["European Call", "European Put", "Fix Asian Call", "Fix Asian put",\
"Float Asian Call","Float Asian Put","Fix Lookback Call","Fix Lookback Put",\
"Float Lookback Call","Float Lookback Put"]
df.index=Change_range
df.index.name="vol of vol"
##################################### visualize ####################################################
df.iplot(title='Change v', xTitle='v', yTitle='Price')
round(df,4)
Analyse: Although the option prices rise as the volatility is rising, this conclusion is not necessarily established for the volatility of volatility. Option prices increase with . if , the situation is same as constant volatility model.
Caculate diffrent option prices with varies from 0.5 to 1.1,step is 0.1.
Change_range=arange(0.5,1.1,0.1)
Change=[]
for b in Change_range:
SV_price_path = pd.DataFrame(SV_simulate_path(s0=100, mu=0.05, beta=b, v=0.5, alpha=0.2, rho=0.2, horizon=1, timesteps=252, n_sims=100000))
reslut_list=caculate_exotic_price(SV_price_path,21,100,0.05,1)
Change.append(reslut_list)
##################################### make table ####################################################
df=pd.DataFrame(Change)
df.columns=["European Call", "European Put", "Fix Asian Call", "Fix Asian put",\
"Float Asian Call","Float Asian Put","Fix Lookback Call","Fix Lookback Put",\
"Float Lookback Call","Float Lookback Put"]
df.index=Change_range
df.index.name="beta"
##################################### visualize ####################################################
df.iplot(title='Change Elasticity of Variance Coefficient', xTitle='Elasticity of Variance Coefficient', yTitle='Price')
round(df,4)
Analyse: Option prices increase with elasticity of variance coefficient rises.
Caculate diffrent option prices with varies from -1 to 1, step is 0.1.
Change_range=arange(-1,1.1,0.1)
Change=[]
for p in Change_range:
SV_price_path = pd.DataFrame(SV_simulate_path(s0=100, mu=0.05, beta=1, v=0.5, alpha=0.2, rho=p, horizon=1, timesteps=252, n_sims=10000))
reslut_list=caculate_exotic_price(SV_price_path,21,100,0.05,1)
Change.append(reslut_list)
##################################### make table ####################################################
df=pd.DataFrame(Change)
df.columns=["European Call", "European Put", "Fix Asian Call", "Fix Asian put",\
"Float Asian Call","Float Asian Put","Fix Lookback Call","Fix Lookback Put",\
"Float Lookback Call","Float Lookback Put"]
df.index=Change_range.round(1)
df.index.name="beta"
##################################### visualize ####################################################
df.iplot(title='Change Correlation Coefficient', xTitle='Correlation Coefficient', yTitle='Prices')
round(df,4)
Analyse: Call options with fixed delivery price increase with the correlation coefficient rises while put options with fixed delivery price decrease with the correlation coefficient rises. Options with floating delivery price have contrary conclusion.
This is a mini project to price exotic options for the appropriate form of payoff, to consider Asian and lookback options using the Euler-Maruyama scheme. These option includes Asian call option with fixed delivery price, Asian put option with fixed delivery price, Asian call option with floating delivery price, Asian put option with floating delivery price, Lookback call option with fixed delivery price, Lookback put option with fixed delivery price, Lookback call option with floating delivery price, Lookback put option with floating delivery price.
We caculate diffrent option prices by sampling by 1 Day, 1 Week, 1 Month, 1 quarter, semi-year, 1 year. Asian call and put with fixed delivery increase with the increase of sampling period. But lookback call and put with fixed delivery has the opposite conclusion.
Then vary the data, we find
Change : all call option prices increase with the rise of while all put option prices decrease. Moreover, the change magnitude of options with fixed delivery price is larger than options with floating delivery price.
Change E: extotic options are all convex functions of the delivery price. The data shows that the convexity in E of Asian option at the money is greater than any others.
Change : all option prices rise as volatility rises. Vega of lookback options is larger than Asian options.
We also simulate underlying asset prices under stochastic volatility asumption, find that:
Contrast constant volatility, simulated underlying asset prices at maturity under atochastic volatility asumption look higher peak and fat tail. Moreover, there are also more extreme data.
We make some detailed exploration for exotic option pricing under stochastic volatility asumption by varing the parameters of stochastic volatility model.
Let dt=1/100, 1/200, 1/300,...1/30000, for fixed dt, we can caculate the mean absolute error of closed-form solutions and numerical solutions. Then we simulate different 100 price paths to caculate mean absolute error, and average them. For every dt,we get a averaged mean absolute error, and plot it.
def analysis_dt(t):
#random.seed(10000)
S0=100
#t=100
sigma=0.2
dt=1/t
r=0.05
W=cumsum([0]+list(random.standard_normal(t)))
S = zeros(t+1)
Sd = zeros(t+1)
S[0] = S0
Sd[0] = S0
for i in range(1,t+1):
z=W[i]-W[i-1]
S[i] = S[i-1] * exp((r - 0.5 * sigma ** 2) * dt + sigma * sqrt(dt) * z)# close-form
Sd[i]=Sd[i-1]+r*Sd[i-1]*dt+sigma * sqrt(dt)*Sd[i-1]*z
return S,Sd
error=[]
sample_num=100
for i in range(1,30):
s=0
for j in range(sample_num):
S,Sd=analysis_dt(100*i)
s+=mean(abs(S-Sd))
error.append(s/sample_num)
plt.plot(1/(100*array(range(1,30))),error)
plt.xlabel('d t')
plt.ylabel('path error')
plt.grid()
If dt=1/252=0.004, path error is 0.1. for S=100, it is very small.
For dt=1/25, we plot closed-form solutions and numerical solutions and compare them.
S,Sd=analysis_dt(25)
df=pd.DataFrame([S,Sd]).T
df.columns=['S closed-form solution','S numerical solution']
df.iplot(title = 'Compare Closed-form Solution and Numerical Solution',color =['cornflowerblue','red'],xTitle='Time Steps', yTitle='Price')
def caculate_exotic_error(S_path,sampling_period,K,r=0.05,T=1):
#sampling_period refers Sampling once every sample_days days
#For example,sample_days=5,meaning that 5,10,15,...,250 are sampled to caculate Asian average and lookback max & min
S=S_path #simulated price path data,expected as a dataframe,of which rows represent time,columns represent every simulated path
sp=sampling_period #
final_price=S.iloc[-1] #final price at maturity
path_mean=S.iloc[sp::sp].mean(axis=0) # state variable MEAN related to sample period,a path has one
path_max=S.iloc[sp::sp].max(axis=0) # state variable MAX related to sample period,a path has one
path_min=S.iloc[sp::sp].min(axis=0) # state variable MIN related to sample period,a path has one
# Calculate the discounted value of the expeced payoff
#vanilla
C0 = exp(-r*T) * std(maximum(final_price - K, 0))
P0 = exp(-r*T) * std(maximum(K - final_price, 0))
#fixed Asian
fix_Asian_C = exp(-r*T) * std(maximum(path_mean - K, 0))
fix_Asian_P = exp(-r*T) * std(maximum(K - path_mean, 0))
float_Asian_C = exp(-r*T) * std(maximum(path_mean - final_price, 0))
float_Asian_P = exp(-r*T) * std(maximum(final_price - path_mean, 0))
fix_Lookback_C = exp(-r*T) * std(maximum(path_max - K, 0))
fix_Lookback_P = exp(-r*T) * std(maximum(K - path_min, 0))
float_Lookback_C = exp(-r*T) * std(maximum(path_max - final_price, 0))
float_Lookback_P = exp(-r*T) * std(maximum(final_price - path_min, 0))
# the caculated results are putted into 'reslut_list' as a list
reslut_list=[C0,P0,fix_Asian_C,fix_Asian_P,float_Asian_C,float_Asian_P,\
fix_Lookback_C,fix_Lookback_P,float_Lookback_C,float_Lookback_P]
return reslut_list
Change_range=[1,5,21,63,126,252] #Sampling by 1 Day,1 Week,1 Month,1 quarter,semi-year,1 year
Change=[]
for d in Change_range:
reslut_list=caculate_exotic_error(price_path,d,K=100,r=0.05,T=1)
Change.append(reslut_list)
df1=pd.DataFrame(Change)*1.96/sqrt(100000)
df1.columns=["European Call", "European Put", "Fix Asian Call", "Fix Asian put",\
"Float Asian Call","Float Asian Put","Fix Lookback Call","Fix Lookback Put",\
"Float Lookback Call","Float Lookback Put"]
df1.index=Change_range
df1.index.name="Sampling Period"
round(df1,4)
#df1 shows random error,95% credit level
Change_range=[1,5,21,63,126,252] #Sampling by 1 Day,1 Week,1 Month,1 quarter,semi-year,1 year
Change=[]
for d in Change_range:
reslut_list=caculate_exotic_price(price_path,d,100,0.05,1)
Change.append(reslut_list)
df2=pd.DataFrame(Change)
df2.columns=["European Call", "European Put", "Fix Asian Call", "Fix Asian put",\
"Float Asian Call","Float Asian Put","Fix Lookback Call","Fix Lookback Put",\
"Float Lookback Call","Float Lookback Put"]
df2.index=Change_range
df2.index.name="Sampling Period"
round(df2,4)
# repeat initial problem to caculate prices,and save to df2
#error percentage
df1/df2
We can see that random error is negligible, about ±1%, under 95% credit level, N=100000. It is necessary to use variance reduction technology if you request a higher digit.